package no.rmz.chez.players;

import no.rmz.chez.movementGeneration.MoveGenerator;
import no.rmz.chez.chess.board.ChessBoard;
import no.rmz.chez.chess.board.Color;
import no.rmz.chez.game.Move;

/**
 * A generic chessplayer, to be subclassed
 * by actual player implementations.
 */
public abstract class ChessPlayer {

    /**
     * The generator of all the moves.
     */
    private final MoveGenerator gen;

    /**
     * The color of this player.
     */
    private Color color;

    /**
     * Set the color of the player.
     * @param c the color
     */
    public final void setColor(final Color c) {
        this.color = c;
    }

    /**
     * Find the color of this player.
     * @return this players color
     */
    public final Color getColor() {
        return color;
    }

    /**
     * Generate a new player with a color.
     * @param c the color.
     */
    public ChessPlayer(final MoveGenerator gen, final Color c) {
        this.color = c;
        this.gen = gen;
    }

    public MoveGenerator getGen() {
        return gen;
    }



    /**
     * Get the next move using whatever strategy this player implements.
     * @param b the board
     * @return the move.
     */
    public Move getNextMove(final ChessBoard b) {
        return gen.getNextMove(getColor(), b);
    }
}
